<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>速报视图</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no,target-densitydpi=device-dpi">
	<link rel="stylesheet" type="text/css" href="JS/bootstrap/bootstrap/dist/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="SWIPER/Swiper/dist/css/swiper.min.css">
	<link rel="stylesheet" type="text/css" href="CSS/home.css">
	<link rel="stylesheet" type="text/css" href="CSS/fixed.css">
	<link rel="stylesheet" type="text/css" href="FONT/style.css">	
	<link rel="stylesheet" type="text/css" href="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.css" >
	<script type="text/javascript" src="JQUERY/bower/jquery/dist/jquery.min.js"></script>
	<script type="text/javascript" src="JS/echart/echarts.min.js"></script>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=k4bHi674VcojGNYv3bwkGtP7XuxMMkPt"></script>
	<script
src="http://maps.google.cn/maps/api/js?key=AIzaSyCbLfKHIBp1w36w3y04cK92v2uYNUuO9OU">
</script>
	<style type="text/css">
	   #googleMap .gmnoprint .gm-style-cc{
        display: none !important;
       }
       #googleMap .gmnoprint.gm-style-cc{
        display: none !important;
       }
       #googleMap img[src*="google4"]{
        display: none;
       }
       #googleMap img[src*="google_white5_hdpi"]{
        display: none;
       }
       </style>
</head>
<body>
	<div class="swiper-container">
		<div class="swiper-header">
			<div class="header-logo">
				<img src="IMAGES/logo/studiesViewlogo.png" />
			</div>
			<div class="header-title">
				<h1>烈度信息</h1>
				<span class="meta-date">2017-07-21</span>
			</div>
			<input type="hidden" id="lat" value="{$data['eqlat']}">
			<input type="hidden" id="lon" value="{$data['eqlon']}">
			<input type="hidden" id="name" value="{$data['eqname']}">
			<input type="hidden" id="province" value="{$data['eqprovince']}">
			<input type="hidden" id="city" value="{$data['eqcity']}">
			<input type="hidden" id="magn" value="{$data['eqmagn']}">
			<input type="hidden" id="int" value="{$data['eqint']}">
			<input type="hidden" id="depth" value="{$data['eqdepth']}">
			<input type="hidden" id="time" value="{$data['eqtime']}">
		</div>
	    <div class="swiper-wrapper">
	    	<!-- <div class="swiper-slide">
	        	{include file="../application/index/view/home/eqmessagel.html" /}
	        </div>
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/eqmessage.html" /}
	        </div> -->
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/eqtomap.html" /}
	        </div>
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/cliConditions.html" /}
	        </div>
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/peoMessage.html" /}
	        </div>
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/econConditions.html" /}
	        </div>
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/enviMessage.html" /}
	        </div>
	        <!-- <div class="swiper-slide">
	        	{include file="../application/index/view/home/topography.html" /}
	        </div> -->
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/tdMaps.html" /}
	        </div>
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/nearFault.html" /}
	        </div>
	        <!-- <div class="swiper-slide">
	        	{include file="../application/index/view/home/asMessage.html" /}
	        </div>
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/asMessagePie.html" /}
	        </div>
	        <div class="swiper-slide">
	        	{include file="../application/index/view/home/goverAction.html" /}
	        </div> -->
	    </div>
	</div>

<script type="text/javascript" src="JS/TrafficControl.js"></script>
<script type="text/javascript" src="SWIPER/Swiper/dist/js/swiper.jquery.min.js"></script>
<script type="text/javascript" src="JS/getData.js"></script>
<script type="text/javascript" src="JS/chart.js"></script>
<script type="text/javascript" src="JS/getAltData.js"></script>
<script type="text/javascript">
// 速报试图
// 作者：赵华
// 时间：2017/8/14
	$(document).ready(function(){
		var SuBao = {};
		SuBao.marker = [];
		SuBao.init = function(){
			//时间
			var d = new Date();
			var year = d.getFullYear();
			var month = d.getMonth() + 1;
			var day = d.getDate();
			$('.swiper-container .swiper-header .meta-date').text(year + '-' + month + '-' + day);
			if(typeof pageTitle === 'undefined') {
				var pageTitle = {
					eqmessagel : '地震信息',
					eqmessage : '地震信息',
					asMessage : '余震信息',
					asMessagePie : '余震信息',
					cliConditions : '气候条件',
					econConditions : '经济情况',
					enviMessage : '环境信息',
					goverAction : '政府行动',
					peoMessage : '人口信息',
					tdMaps : '三维地形图',
					topography : '地形地貌',
					eqtomap: '烈度信息',
					nearFault:'附近断裂'
				}
			}

			var swiperOption = {
				onTransitionEnd: function(swiper) {
					var _this = swiper;
					var _wiper = $(_this.$.find('.swiper-slide-active'));
					var name = _wiper.find('.page-wiper')[0].classList[1];
					var title = pageTitle[name];
					$('.header-title h1').text(title);
					if(title=="附近断裂"){
					   addlatLng(mapFault,1);
					   mapFault.addEventListener('zoomend',function(e){
					   	   // alert(mapFault.getZoom());
						    clearOver(mapFault);
						    if(mapFault.getZoom()==7){
					   	    	addlatLng(mapFault,2);
					   	    }else if(mapFault.getZoom()==6){
					   	    	addlatLng(mapFault,3);
					   	    }else if(mapFault.getZoom()==5){
					   	    	addlatLng(mapFault,5);
					   	    }else if(mapFault.getZoom()==4){
					   	    	addlatLng(mapFault,9);
					   	    }else if(mapFault.getZoom()==3){
					   	    	addlatLng(mapFault,12);
					   	    }else{
					   	    	addlatLng(mapFault,1);
					   	    }
						    
						});
						mapFault.addEventListener('moveend',function(e){
							clearOver(mapFault);
						    if(mapFault.getZoom()==7){
					   	    	addlatLng(mapFault,2);
					   	    }else if(mapFault.getZoom()==6){
					   	    	addlatLng(mapFault,3);
					   	    }else if(mapFault.getZoom()==5){
					   	    	addlatLng(mapFault,5);
					   	    }else if(mapFault.getZoom()==4){
					   	    	addlatLng(mapFault,9);
					   	    }else if(mapFault.getZoom()==3){
					   	    	addlatLng(mapFault,12);
					   	    }else{
					   	    	addlatLng(mapFault,1);
					   	    }
						})
					}
				}
			};

			var mySwiper = new Swiper('.swiper-container',swiperOption);
			function addlatLng(map,param){
			    var southWest=map.getBounds().getSouthWest();
			    var northEast=map.getBounds().getNorthEast();

			   for(var i=0;i<(northEast.lng-southWest.lng).toFixed(0);i=i+param){
			      var markerTop=new BMap.Marker(new BMap.Point(southWest.lng+i, northEast.lat));
			      var markerBottom=new BMap.Marker(new BMap.Point(southWest.lng+i, southWest.lat));
			      // map.addOverlay(markerTop);
			      // map.addOverlay(markerBottom);
			      var optsTop = {
			        position : new BMap.Point(southWest.lng+i, northEast.lat),    // 上边界
			        offset   : new BMap.Size(0,0)    //设置文本偏移量
			      }
			      var labelTop = new BMap.Label((southWest.lng+i).toFixed(0)+'°  E', optsTop);  // 创建文本标注对象
			      labelTop.flag="myLable";
			      addLabelStyle(map,labelTop);
			      var optsBottom={
			        position : new BMap.Point(southWest.lng+i, southWest.lat),    // 下边界
			        offset   : new BMap.Size(0, -20)    //设置文本偏移量
			      }
			      var labelBottom = new BMap.Label((southWest.lng+i).toFixed(0)+'°  E', optsBottom);
			      labelBottom.flag="myLable";
			      addLabelStyle(map,labelBottom)
			   }
			   for(var j=0;j<(northEast.lat-southWest.lat).toFixed(0);j=j+param){
			      var left=new BMap.Marker(new BMap.Point(southWest.lng,southWest.lat+j));
			      var right=new BMap.Marker(new BMap.Point(northEast.lng,southWest.lat+j));
			      var optsLeft = {
			        position : new BMap.Point(southWest.lng,southWest.lat+j),   //左边界
			        offset   : new BMap.Size(0,0)    
			      }
			      var labelLeft = new BMap.Label((southWest.lat+j).toFixed(0)+'° N', optsLeft);  // 创建文本标注对象
			      labelLeft.flag="myLable";
			      addLabelStyle(map,labelLeft);

			      var optsRight = {
			        position : new BMap.Point(northEast.lng,southWest.lat+j),   //右边界
			        offset   : new BMap.Size(-40,0)    
			      }
			      var labelRight = new BMap.Label((southWest.lat+j).toFixed(0)+'° N', optsRight);  // 创建文本标注对象
			      labelRight.flag="myLable";
			      addLabelStyle(map,labelRight);

			    }
			  }
			  function addLabelStyle(map,label){   
			      label.setStyle({
			         color : "black",
			         fontSize : "12px",
			         height : "20px",
			         lineHeight : "20px",
			         fontFamily:"微软雅黑",
			         backgroundColor:'transparent',//文本背景色
			         borderColor:'transparent',//文本框边框色
			         //fontWeight:"bold"
			       });
			       map.addOverlay(label);   
			  }
			  function clearOver(map){
				    var overlays=map.getOverlays();
				    for(var i=0;i<overlays.length;i++){
				      if(overlays[i].flag=="myLable"){
				         map.removeOverlay(overlays[i]);
				      }
				    }
			  }
		};

		(function(){
			//分辨率适应
			var pageWidth = document.documentElement.clientWidth || document.body.clientWidth;
			var pageHeight = document.documentElement.clientHeight || document.body.clientHeight;
			$('.swiper-container').css({
				'width': pageWidth + 'px',
				'height': pageHeight + 'px'
			});
		})();
		//获取所有数据
		SuBao.getData = function(){
			var city = $('#name').val();
			var pro = $('#province').val();
			var data = {
				city : city,
				pro: pro
			};
			var p =GetData(data);
			//渲染页面
			//地图实例
			var HIS_EU = {
				Area: '面积',
				CrackDegree: '预估烈度',
				Death: '死亡人数',
				DirectEconomicLoss: '直接经济损失',
				EarthquakeDate: '时间',
				Latitude: '纬度',
				Longitude: '经度',
				Macro_epicenter: '地点',
				Magnitude: '震级'
			};
			var NEAR_EU = {
				name: '城镇',
				GDP: '生产总值(亿)',
				POP_ALL: '总人口',
				area: '面积',
				distence: '距震中距离',
				latitude: '纬度',
				longtitude: '经度'
			};
			var EQ_CENTER_EU = {
				province: '所属省',
				city: '所属市',
				name: '震中',
				time: '时间',
				lat: '纬度',
				lon: '经度',
				magn: '震级',
				int: '预估烈度',
				depth: '深度'
			};
			var MAP_ICON_SIZE = 20;
			var CHECKED_IMG = 'IMAGES/mapimg/checked.png';
			var NOCHECKED_IMG = 'IMAGES/mapimg/nochecked.png';
			var NO_ROAD_MES =[
                         {
                                   "featureType": "road",
                                   "elementType": "all",
                                   "stylers": {
                                             "visibility": "off"
                                   }
                         }
                    ];
            var ROAD_MES = [
                         {
                                   "featureType": "road",
                                   "elementType": "all",
                                   "stylers": {
                                             "visibility": "on"
                                   }
                         }
                    ];
			var center = {lon:parseFloat($('#lon').val()), lat:parseFloat($('#lat').val())};
			var CENTER_MARKER = 'IMAGES/mapimg/centerstar2.png';
			var NEAR_CITY_MARKER = 'IMAGES/mapimg/nearCity3.png';
			var HIS_EQ_MARKER_1 = 'IMAGES/icon/tdhis1.png';
			var HIS_EQ_MARKER_2 = 'IMAGES/icon/tdhis2.png';
			var HIS_EQ_MARKER_3 = 'IMAGES/icon/tdhis3.png';
			var HIS_EQ_MARKER = [HIS_EQ_MARKER_1, HIS_EQ_MARKER_2, HIS_EQ_MARKER_3];
			var CURRENT_CITY = $('#name').val();	
			p.exportDataTd(function (data) {
				if(!data) return;
				var _data = data.data;
				if(_data) {
					var map = BMinit('BMap', center, _data);
					if (!_data.nearCityData) return;
					var countydesc = setMapNearCityDesc(_data,getEqCenterMes());
				}
			})

			var Alt = GetAlt(center);

			//天气信息
			p.exportDataCli(function(data) {
				if(!data) return;
				var _data = data.clidata;
				var _datadescription = data.clidescription.climate;
				var d = new Date();
				var year = d.getFullYear();
				var month = d.getMonth() + 1;
				var forecast = _data.forecast.weather;
					var regstr = /[\u4e00-\u9fa5]|[℃]/g;
					var trange = forecast[0].low.replace(regstr,'') + '~' + forecast[0].high.replace(regstr,'') + '℃' ;
					//xml格式去除；
					var fenji = _data.fengli;
					var twhumidity = _data.shidu;
					var fengxiang = _data.fengxiang;
					var day = forecast[0].date.replace(regstr,'');
					$('.cliConditions .cli-header .te-range span').text(trange);
					$('.cliConditions .cli-header .te-description .te-humidity span').text(twhumidity);
					$('.cliConditions .cli-header .te-description .te-direct span').text(fengxiang);
					$('.cliConditions .cli-header .te-description .te-wind span').text(fenji);
					$('.cliConditions .cli-meta').text(year + '-' + month + '-' + day);
					//指数列表
					var zhishus = getZhishu(_data.zhishus.zhishu);
					$('.cliConditions .cli-header .te-zhishus').append(createdZhishufra(zhishus));
							//渲染列表
					$('.cliConditions .cli-list-container .cli-ul .cli-ul-row').each(function (i,ev) {
								var time = forecast[i + 1].date;
								var wet = forecast[i + 1].day.type;
								var temp = forecast[i + 1].low.replace(regstr,'') + '~' + forecast[i + 1].high.replace(regstr,'') + '℃' ;
								$(ev).find('.cli-ul-row-left .meta-time').text(time);
								$(ev).find('.cli-ul-row-left .meta-wet').text(wet);
								$(ev).find('.cli-ul-row-right .meta-temp').text(temp);
							});
					$('.cliConditions .cli-describe .text-container p').text(_datadescription);
			});

			//人口信息
			p.exportDataPeo(function(data) {
				if(!data) return;
				var _data = data.data[0];
				var all = _data.POP_ALL;
				$('.peoMessage .peo-header .peo-num').text(all || '');
				if(!_data.villageAverIncom){
					$('.peo-descript-down').css('visibility','hidden') // 乡村人均收入隐藏
				}else{
					$('.peo-descript-down .meta-num').text(_data.villageAverIncom || '') // 乡村人均收入
				}
				if(!_data.urbanAverIncome){
					$('.peo-descript-city').css('visibility','hidden') // 乡村人均收入隐藏
				}else{
					$('.peo-descript-city .meta-num').text(_data.urbanAverIncome || '') // 农村人均收入
				}
				if(!_data.townNum){
					$('.toci-all .town-num').css('visibility','hidden') // 乡村人均收入隐藏
				}else{
					$('.toci-all .town-num .meta-num').text(_data.townNum || '') // 乡镇数目
				}
				if(!_data.villageNum){
					$('.toci-all .city-num').css('visibility','hidden') // 乡村人均收入隐藏
				}else{
					$('.toci-all .city-num .meta-num').text(_data.villageNum || '') // 行政村数目
				}
				var townData = parseFloat(_data.POP_COUNTRYSIDE) || 0;//农村人口
				var countryData =  parseFloat(_data.POP_TOWN) || 0;//城市人口
				var PopDesc=null;
				PopDesc = "据《中国2010年人口普查分县资料》，" + _data.eqtname + "在2010年的总人口约" + all + "万人。在总人口中，城镇人口约" + countryData + "万人,占总人口的" + (countryData/(countryData+townData)*100).toFixed(2) + "%;农业人口约" + townData + "万人,占总人口的" + (townData/(countryData+townData)*100).toFixed(2) + "%。";
					if(_data.POP_ALL!=null&&countryData!=null&&townData!=null){
							 PopDesc = "据《中国2010年人口普查分县资料》，" + _data.eqtname + "在2010年的总人口约" + all + "万人。";
						if(countryData){
							PopDesc=PopDesc+"在总人口中，城镇人口约" + countryData + "万人，占总人口的" + (countryData/(countryData+townData)*100).toFixed(2) + "%";
						}
						if(townData){
							PopDesc=PopDesc+"，农业人口约" + townData + "万人，占总人口的" + (townData/(countryData+townData)*100).toFixed(2) + "%。";
						}
						
					}
					
				$('.peoMessage .peo-description .text-container p').text(PopDesc || '');
				var chartData = [townData, countryData];
				var chartType = 'Pie';
				var chartId = 'peoChart';
				Chart(chartType, chartData, chartId);
			})
			//经济信息
			p.exportDataEcon(function(data) {
				if(!data) return;
				var _data = data.data[0];
				$('.econConditions .econ-num').text(parseFloat(_data.GDP).toFixed(2) || '');
				
				//var EconDesc = "据《中国经济年鉴2014》，" + _data.eqtname + "在2014年的生产总值达" + parseFloat(_data.GDP).toFixed(2) + "万元，第一产业总值为" + _data.FST_INDUSTRY + "万元，第二生产总值为"+ _data.SND_INDUSTRY + "万元，第三产业生产总值为" + _data.TRD_INDUSTRY  + "万元。";
				
				if(_data.GDP=='0'&&_data.FST_INDUSTRY=='0'&&_data.SND_INDUSTRY=='0'&&_data.TRD_INDUSTRY=='0'){
					EconDescp="无数据"
				}else{
					var EconDescp="据《中国经济年鉴2014》，"+_data.eqtname;
					if(_data.GDP!=='0'&&_data.GDP!=='0.0'){
						EconDescp=EconDescp+"在2014年的生产总值达" + parseFloat(_data.GDP).toFixed(2) + "亿元";
					}
					if(_data.FST_INDUSTRY!=='0'&&_data.FST_INDUSTRY!=='0.0'){
						EconDescp=EconDescp+"，第一产业生产总值为" + _data.FST_INDUSTRY + "亿元";
					}
					if(_data.SND_INDUSTRY!=='0'&&_data.SND_INDUSTRY!=='0.0'){
						EconDescp=EconDescp+"，第二产业生产总值为"+ _data.SND_INDUSTRY + "亿元";
					}
					if(_data.TRD_INDUSTRY!=='0'&&_data.TRD_INDUSTRY!=='0.0'){
						EconDescp=EconDescp+"，第三产业生产总值为" + _data.TRD_INDUSTRY  + "亿元";
					}
					EconDescp=EconDescp+"。 ";
				}
				



				$('.econConditions .econ-description .text-container p').text(EconDescp || '');

				var firData = _data.FST_INDUSTRY || 0;
				var secData = _data.SND_INDUSTRY || 0;
				var thrData = _data.TRD_INDUSTRY || 0;
				var chartData = [firData, secData, thrData];
				var chartType = 'PencilBar';
				var chartId = 'econChart';
				Chart(chartType, chartData, chartId);
			});
			//环境信息
			p.exportDataEnvir(function(data) {
				if(!data) return;
				var _data = data.data[0];
				$('.enviMessage .envi-num').text(_data.altitudeCenter+"m" || '无数据');
				$('.enviMessage .envi-description .text-container p').text(_data.topographic || '无数据');
				$('.topography .topo-container .topo-header span').text(_data.eqtname + '地区地形地貌图' || '无数据');
				$('.topography .topo-description .text-container p').text(_data.topographic || '无数据');
				var firData = parseFloat(_data.altitudeL || 0);
				var secData = parseFloat(_data.altitudeAverage || 0).toFixed(2);
				var thrData = parseFloat(_data.altitudeH || 0);
				var chartData = [firData, secData, thrData];
				var chartType1 = 'ShadowBar';
				var chartId1= 'enviChart';
				var chartType2 = 'Line';
				var chartId2 = 'topoChart';
				Chart(chartType1, chartData, chartId1);
				Chart(chartType2, chartData, chartId2)
			});
			//三维地图
			p.exportDataTd(function(data) {
				if(!data) return;
				var _data = data.data;
				if(_data) {
					TDinit('googleMap', center, _data);
					setTdTemplate(_data);
				}
				var h = $('.tdMaps');
			});
			function TDinit(id, center, eqData){
				// console.log(center)
				// console.log("经度："+center.lon)
				var mapProp = {
			        center:new google.maps.LatLng(center.lat,center.lon),
			        disableDefaultUI: true,  
			        zoom:9,
			        mapTypeId:google.maps.MapTypeId.HYBRID,
			        scaleControl:true,
			        scaleControlOptions: {  
			       	 style: google.maps.ControlPosition.BOTTOM_LEFT  
			    	}
			    	// ,
			    	// draggable:false
			    };
			    var map=new google.maps.Map(document.getElementById("googleMap"), mapProp);	 
			   	var nearPointsList = eqData.nearCityData ? setNearCityGoogle(map, eqData.nearCityData) : [];
				var hisPointsList = eqData.hisEqData ? setHisEqGoogle(map, eqData.hisEqData) : [];
				//var pointList = nearPointsList.concat(hisPointsList);
				setVeiwPort(nearPointsList,map);
			}
			//展示最佳视野的函数  
			var setVeiwPort = function (markers,gmap) {  
			    var bounds = new google.maps.LatLngBounds();  
			    //读取标注点的位置坐标，加入LatLngBounds  
			    for(var i = 0;i < markers.length;i++){  
			        bounds.extend(markers[i].getPosition());  
			    }  
			    //调整map，使其适应LatLngBounds,实现展示最佳视野的功能  
			    gmap.fitBounds(bounds);  
			};  

			//百度地图API
			function BMinit(id, center, eqData) {
				var map = new BMap.Map(id,{
					minZoom:4
				});           // 创建Map实例
				var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});// 左上角，添加比例尺
				top_left_control.setOffset(new BMap.Size(45, 20))
				
				map.addControl(top_left_control);
				var point = new BMap.Point(center.lon, center.lat); // 创建点坐标
				var centerIcon = new BMap.Icon(CENTER_MARKER, new BMap.Size(MAP_ICON_SIZE, MAP_ICON_SIZE));
				var centerMarker = new BMap.Marker(point, {icon: centerIcon});
				var eqmes = getEqCenterMes();
				var content = setEqCenterContent('震中信息', eqmes);
				//setInfoWindow(map, content, point);
				centerMarker.addEventListener('click', function() {
						setInfoWindow(map, content, point);
					})
				map.addOverlay(centerMarker);
				//setIntensityCricle(map, point, eqmes.magn);

				var nearPointsList = eqData.nearCityData ? setNearCity(map, eqData.nearCityData,center) : [];
				var hisPointsList = eqData.hisEqData ? setHisEq(map, eqData.hisEqData) : [];
				var pointList = nearPointsList.concat(hisPointsList);
				pointList.push(point);
				var view = map.getViewport(eval(pointList));  
				var mapZoom = view.zoom;
				/*map.setCurrentCity(CURRENT_CITY);*/
				//centerAndZoom(map, point, 7);
				if(eqData.countyData)
				{
					setCounty(map,eqData.countyData);
				}
				addlatLng(map,0.5);
				map.addEventListener('zoomend',function(e){
				    clearOver(map);
				    if(map.getZoom()==8){
				    	addlatLng(map,1);
				    }else if(map.getZoom()==7){
					   	addlatLng(map,2);
					}else if(map.getZoom()==6){
					   	addlatLng(map,3);
					}else if(map.getZoom()==5){
					   	addlatLng(map,5);
					}else if(map.getZoom()==4){
					   	addlatLng(map,9);
					}else if(map.getZoom()==3){
					   	addlatLng(map,12);
					}else{
					   	addlatLng(map,0.5);
					}
				});
				map.addEventListener('moveend',function(e){
					clearOver(map);
				    if(map.getZoom()==8){
				    	addlatLng(map,1);
				    }else if(map.getZoom()==7){
					   	addlatLng(map,2);
					}else if(map.getZoom()==6){
					   	addlatLng(map,3);
					}else if(map.getZoom()==5){
					   	addlatLng(map,5);
					}else if(map.getZoom()==4){
					   	addlatLng(map,9);
					}else if(map.getZoom()==3){
					   	addlatLng(map,12);
					}else{
					   	addlatLng(map,0.5);
					}
				})
				// 通过JavaScript的prototype属性继承于BMap.Control
				LegnedControl.prototype = new BMap.Control();
				ToEqCenter.prototype = new BMap.Control();
				TrafficLayerControl.prototype = new BMap.Control();
				FaultControl.prototype=new BMap.Control();
				TrafficInfo.prototype = new BMap.Control();
				// 自定义控件必须实现自己的initialize方法,并且将控件的DOM元素返回
				// 在本方法中创建个div元素作为控件的容器,并将其添加到地图容器中
				LegnedControl.prototype.initialize = function(map){
				  // 创建一个DOM元素
				  var div = document.createElement("div");
				  div.className = 'legend';
				  div.setAttribute('ref', 'tuli');
				  div.innerHTML = "<h4 class='ltitle'>图例</h4><label>震中:<span class='item'><img src='IMAGES/mapimg/centerstar.png' /></span></label><label>附近城镇:<span class='item'><img src='IMAGES/mapimg/nearCity.png' /></span></label><label>历史地震:<span class='item'><img src='IMAGES/icon/tdhis1.png' /></span></label><label>实时路况:<span class='item'><img src='IMAGES/mapimg/road1.png' /></span></label><label>县城距离:<span class='item'><img src='IMAGES/mapimg/nearCityLegend.png' /></span></label><label>县城边界:<span class='item'><img src='IMAGES/mapimg/boundaryLegend.png' /></span></label> ";
				  // 添加DOM元素到地图中
				  map.getContainer().appendChild(div);
				  // 将DOM元素返回			      
				  return div;
				}
				ToEqCenter.prototype.initialize = function(map){
				  // 创建一个DOM元素
				  var div = document.createElement("div");
				  div.className = 'eqCenter';
				  div.innerHTML = '<button class="eq-center"></button>';
				  div.onclick = function(e) {
				  	centerAndZoom(map, point, mapZoom);
				  }
				  // 添加DOM元素到地图中
				  map.getContainer().appendChild(div);
				  // 将DOM元素返回
				  return div;
				}
				FaultControl.prototype.initialize=function(map){
				  var div = document.createElement("div");
				  div.className = 'eqCenter';
				  div.innerHTML = '<img src="IMAGES/mapimg/compass.png" style="width:4rem;height:4rem"></img>';
				  div.onclick = function(e) {
				  	centerAndZoom(map, point, mapZoom);
				  }
				  // 添加DOM元素到地图中
				  map.getContainer().appendChild(div);
				  // 将DOM元素返回
				  return div;
				}

				TrafficLayerControl.prototype.initialize = function(map){
				  // 创建一个DOM元素
				  var div = document.createElement("div");
				  div.className = 'track';
				  div.innerHTML = '<span class="track-icon" data="checked"><img src="IMAGES/mapimg/checked.png"></span><span class="track-title">路网</span>';
				  div.onclick = function() {
				  	var _this = this;
				  	var parentNode = _this.childNodes[0];
				  	var node = parentNode.childNodes[0];
				  	var currentData = _this.childNodes[0].attributes[1].nodeValue;
				  	if(currentData === 'nochecked') {
				  		node.setAttribute('src', CHECKED_IMG);
				  		parentNode.setAttribute('data', 'checked');
				  		map.setMapStyle({styleJson: ROAD_MES});
				  	}else{
				  		node.setAttribute('src', NOCHECKED_IMG);
				  		parentNode.setAttribute('data', 'nochecked');
				  		map.setMapStyle({styleJson: NO_ROAD_MES});
				  	}
				  }
				  // 添加DOM元素到地图中
				  map.getContainer().appendChild(div);
				  // 将DOM元素返回
				  return div;
				}
				TrafficInfo.prototype.initialize = function(map){
				  // 创建一个DOM元素
				  var div = document.createElement("div");
				  var _trafficLayer;
				  div.className = 'Traffic';
				  //div.innerHTML = '';
				  div.onclick = function(e) {
				  		if(!this._trafficLayer){
				  			var trafficLayer = new BMap.TrafficLayer();
				  			this._trafficLayer = trafficLayer;
				  			map.addTileLayer(this._trafficLayer);
				  		}else{
				  			map.removeTileLayer(this._trafficLayer);
				  			this._trafficLayer = null;
				  		}				  		
				  }
				  // 添加DOM元素到地图中
				  map.getContainer().appendChild(div);
				  // 将DOM元素返回
				  return div;
				}
				// 创建控件
				var myLegnedControl = new LegnedControl();
				var myToEqCenter = new ToEqCenter();
				var myTrafficLayerControl = new TrafficLayerControl();
				var myTrafficInfo = new TrafficInfo();
				var myFaultControl=new FaultControl();
				//var myTrafficControl = new BMapLib.TrafficControl();
				// 添加到地图当中
				map.addControl(myLegnedControl);
				map.addControl(myToEqCenter);
				map.addControl(myTrafficLayerControl);
				map.addControl(myTrafficInfo);
				map.addControl(myFaultControl);
				var navOpt = {type: BMAP_NAVIGATION_CONTROL_ZOOM,offset:new BMap.Size(10, 260)};   
				var mapType={type:BMAP_MAPTYPE_CONTROL_HORIZONTAL,offset:new BMap.Size(5, 20)}        
				map.addControl(new BMap.NavigationControl(navOpt)); 
				map.addControl(new BMap.OverviewMapControl());    
				map.addControl(new BMap.MapTypeControl(mapType));
				return map;
			}
			//海拔信息
			Alt.getInfo(function(center){
				if(!center)return;
				elevation = center.results[0].elevation
				var k = $('.envi-num.num')[0]
				console.log(elevation);
				console.log(k);
				k.innerText = elevation.toFixed(2)+'m';
				//console.log(center);
			})
			function setNearCity(map, nearCity,center) {
				var points = [];
				nearCity.forEach(function(item, index) {
					if(item.longtitude && item.latitude) {
						if(index!=0){
							//第一个点为震中，已添加
							var point = new BMap.Point(item.longtitude, item.latitude);
							var icon = new BMap.Icon(NEAR_CITY_MARKER, new BMap.Size(MAP_ICON_SIZE, MAP_ICON_SIZE));
							var marker = new BMap.Marker(point, {icon: icon});
							/*var _markerMK = {
								id: 'near' + index,
								marker: marker
							};
							this.marker.push(_markerMK);*/
							var content = setNearContent('附近城镇信息', item);
							marker.addEventListener('click', function() {
								setInfoWindow(map, content, point);
							})
							map.addOverlay(marker);
							points.push(point);
							//添加折线
							var polyline=new BMap.Polyline([new BMap.Point(center.lon, center.lat),new BMap.Point(item.longtitude,item.latitude)],{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5});
							map.addOverlay(polyline); 
							polyline.disableMassClear()
							var opts = {
							  position : point,    // 指定文本标注所在的地理位置
							  offset   : new BMap.Size(-15,-30)    //设置文本偏移量
							}
							var label = new BMap.Label(item.distence.toFixed(0)+"公里", opts);  // 创建文本标注对象
								label.setStyle({
									 color : "red",
									 fontSize : "12px",
									 height : "20px",
									 lineHeight : "20px",
									 fontFamily:"微软雅黑"
								 });
							map.addOverlay(label);  

						}
						
						index++;
					}
				})
				map.setViewport(points);
				return points;
			}
			function setNearCityGoogle(map, nearCity) {
				var points = [];
				var center;
				nearCity.forEach(function(item, index) {
					if(item.longtitude && item.latitude) {
						//google
						if(index==0){
							center=item;
							var nearIcon={
						    	url:CENTER_MARKER,
						    }
							var Marker=new google.maps.Marker({
							    position:new google.maps.LatLng(item.latitude,item.longtitude),
							    icon:nearIcon
							});
							var content = setNearContent('震中信息', item);
							var infowindow = new google.maps.InfoWindow({
							  content:content
							});
							google.maps.event.addListener(Marker, 'click', function() {
							  infowindow.open(map,Marker);
							});
							Marker.setMap(map);
						}else{
							var nearIcon={
						    	url:NEAR_CITY_MARKER,
						    }
							var Marker=new google.maps.Marker({
							    position:new google.maps.LatLng(item.latitude,item.longtitude),
							    icon:nearIcon
							});
							var content = setNearContent('附近城镇信息', item);
							var infowindow = new google.maps.InfoWindow({
							  content:content
							});
							google.maps.event.addListener(Marker, 'click', function() {
							  infowindow.open(map,Marker);
							});
							Marker.setMap(map);
							var polyline=new google.maps.Polyline({
								path:[new google.maps.LatLng(center.latitude,center.longtitude),new google.maps.LatLng(item.latitude,item.longtitude)],
								strokeColor:"blue",
								strokeWeight:2

							});
							polyline.setMap(map);
						}						
						points.push(Marker);
						index++;
					}
				})
				return points;
			}
			function setHisEq(map, hisEq) {
				var points = [];
				var index = 0;
				for(var key in hisEq) {
					if(hisEq.hasOwnProperty(key) && hisEq[key] !== '') {
						var val = hisEq[key];
						var point = new BMap.Point(val.Longitude, val.Latitude);
						var icon = new BMap.Icon(HIS_EQ_MARKER[index], new BMap.Size(MAP_ICON_SIZE, MAP_ICON_SIZE));
						var marker = new BMap.Marker(point, {icon: icon});
						/*var _markerMK = {
							id: 'his' + key,
							marker: marker
						};
					this.marker.push(_markerMK);*/
						(function(item, poi){
							var content = setHisContent('历史地震信息', item);
							marker.addEventListener('click', function() {
								setInfoWindow(map, content, poi);
							});
						})(val, point)
						map.addOverlay(marker);
						points.push(point);
						index++;
					}
				}
				return points;
			}
			function setHisEqGoogle(map, hisEq) {
				var points = [];
				var index = 0;
				for(var key in hisEq) {
					if(hisEq.hasOwnProperty(key) && hisEq[key] !== '') {
						var val = hisEq[key];
						//google
						 var hisIcon={
					    	url:HIS_EQ_MARKER[index],
					    	//size:new google.maps.Size(MAP_ICON_SIZE,MAP_ICON_SIZE)
					    }
						var Marker=new google.maps.Marker({
						    position:new google.maps.LatLng(val.Latitude,val.Longitude),
						    icon:hisIcon
						});
						(function(item, Marker){	
							var content = setHisContent('历史地震信息', item);
							var infowindow = new google.maps.InfoWindow({
							  content:content
							});
							google.maps.event.addListener(Marker, 'click', function() {
							  infowindow.open(map,Marker);
							});
							
						})(val, Marker)
						Marker.setMap(map);
						points.push(Marker);
						index++;
					}
				}
				return points;
			}
			function setInfoWindow(map, content, point) {
				var infoWindow = new BMap.InfoWindow(content);  // 创建信息窗口对象 
				map.openInfoWindow(infoWindow,point); //开启信息窗口
			}
			// 定义一个控件类,即function
			function LegnedControl(){
			  // 默认停靠位置和偏移量
			  this.defaultAnchor = BMAP_ANCHOR_BOTTOM_RIGHT;
			  this.defaultOffset = new BMap.Size(10, 20);
			}
			// 控件类 
			function ToEqCenter () {
				// 默认停靠位置和偏移量
			  this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
			  this.defaultOffset = new BMap.Size(10, 60);
			}
			function TrafficLayerControl () {
				// 默认停靠位置和偏移量
			  this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
			  this.defaultOffset = new BMap.Size(10, 100);
			}
			function FaultControl(){
				// 默认停靠位置和偏移量
			  this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
			  this.defaultOffset = new BMap.Size(0, 15);
			}
			function TrafficInfo () {
				// 默认停靠位置和偏移量
			  this.defaultAnchor = BMAP_ANCHOR_BOTTOM_LEFT;
			  this.defaultOffset = new BMap.Size(5, 15);
			}
			function setNearContent (title, data) {
				var itemcontent = [];
				var header = '<div class="eqmes-info"><h4 class="info-title">' + title + '</h4><div class="info-content"><table class="table table-bordered table-hover table-condensed">';
				for(var item in data) {
					if(data.hasOwnProperty(item)){
						if(item === 'latitude' || item === 'longtitude')
						{
							data[item] = parseFloat(data[item]).toFixed(2);
						}
						var _itemcontent = '<tr class="info-item"><td><label>' + NEAR_EU[item] + '<span><img src="IMAGES/mapimg/nearCity.png"></span></label></td><td><span>' + data[item] + '</span></td></tr>';
						itemcontent.push(_itemcontent);
					}
				}
				var foot = '</div></div>';
				header += itemcontent.join('');
				var content = header + foot;
				return content;
			}
			function setHisContent (title, data) {
				var itemcontent = [];
				var header = '<div class="eqmes-info"><h4 class="info-title">' + title + '</h4><div class="info-content"><table class="table table-bordered table-hover table-condensed">';
				for(var item in data) {
					if(data.hasOwnProperty(item) && item !== 'OBJECTID'){
						if(item === 'Latitude' || item === 'Longitude' )
						{
							data[item] = parseFloat(data[item]).toFixed(2);
						}
						var _itemcontent = '<tr class="info-item"><td><label>' + HIS_EU[item] + '<span><img src="IMAGES/icon/tdhis1.png"></span></label></td><td><span>' + data[item] + '</span></td></tr>';
						itemcontent.push(_itemcontent);
					}
				}
				var foot = '</div></div>';
				header += itemcontent.join('');
				var content = header + foot;
				return content;
			}
			function setEqCenterContent (title, data) {
				var itemcontent = [];
				var header = '<div class="eqmes-info"><h4 class="info-title">' + title + '</h4><div class="info-content"><table class="table table-bordered table-hover table-condensed">';
				for(var item in data) {
					if(data.hasOwnProperty(item) && item !== 'OBJECTID'){
						if(item === 'lat' || item === 'lon' )
						{
							data[item] = parseFloat(data[item]).toFixed(2);
							if(item === 'lon')
							{
								var _itemcontent = '<tr class="info-item"><td><label>' + EQ_CENTER_EU['lat'] + ' , ' + EQ_CENTER_EU['lon'] + '<span><img src="IMAGES/mapimg/centerstar.png"></span></label></td><td><span>' + data["lat"] + ' , ' + data["lon"] + '</span></td></tr>';
								itemcontent.push(_itemcontent);
							}
						}else{
							if (item === 'int') 
							{
								data[item] = getRoma(parseInt(data[item]));
							}
							var _itemcontent = '<tr class="info-item"><td><label>' + EQ_CENTER_EU[item] + '<span><img src="IMAGES/mapimg/centerstar.png"></span></label></td><td><span>' + data[item] + '</span></td></tr>';
							itemcontent.push(_itemcontent);
						}
						
					}
				}
				var foot = '</table></div></div>';
				header += itemcontent.join('');
				var content = header + foot;
				return content;
			}
			function getEqCenterMes() {
				var eqmes = {};
				eqmes.name = $('#name').val();
				eqmes.province = $('#province').val();
				eqmes.city = $('#city').val();
				eqmes.lat = $('#lat').val();
				eqmes.lon = $('#lon').val();
				eqmes.time = $('#time').val();
				eqmes.magn = $('#magn').val();
				eqmes.int = $('#int').val();
				eqmes.depth = $('#depth').val();
				return eqmes;
			}
			function centerAndZoom(map, centerPoint, zoom) {
				map.centerAndZoom(centerPoint, zoom)
			}
			function getRoma(num) {
				var lap = ['I', 'V', 'X', 'L', 'C', 'D', 'M'];
				var roma = '';
				var bit = 0;
				while(num > 0) {
					var tempnum = num % 10;
					switch(tempnum) {
						case 3:
							roma = lap[bit] + roma;
							tempnum--;
						case 2:
							roma = lap[bit] + roma;
							tempnum--;
						case 1:
						    roma = lap[bit] + roma;
						    break;
						case 4:
							roma = lap[bit + 1] + roma;
							roma = lap[bit] + roma;
							break;
						case 8:
							roma = lap[bit] + roma;
							tempnum--;
						case 7:
							roma = lap[bit] + roma;
							tempnum--;
						case 6:
							roma = lap[bit] + roma;
							tempnum--;
						case 5:
						    roma = lap[bit + 1] + roma;
						    break;
						case 9:
							roma = lap[bit + 2] + roma;
							roma = lap[bit] + roma;
							break;
						default:
							break;
					}
					bit += 2;
					num = Math.floor(num / 10);
				}
				return roma;
			}
			function setTdTemplate(_data) {
				var flag=0
				if(_data.nearCityData) {
					$('.tdMaps .td-near .near-mes').each(function (i, ev) {
						$(ev).find('.header .title-width').attr('title',_data.nearCityData[i].name || '无数据')
						$(ev).find('.header .title').text(_data.nearCityData[i].name || '无数据');
						$(ev).find('.header .meta-distance').text(_data.nearCityData[i].distence || '无数据');
						$(ev).find('.body .area .area-num').text(_data.nearCityData[i].area || '无数据');
						$(ev).find('.body .economy .economy-num').text(parseFloat(_data.nearCityData[i].GDP).toFixed(2) || '无数据');
						$(ev).find('.body .population .population-num').text(parseFloat(_data.nearCityData[i].POP_ALL).toFixed(2) || '无数据');
					})
				}
				if(_data.hisEqData) {
					$('.tdMaps .td-history .his-container .his-list .his-list-item').each(function (i, ev) {
					
						if(i === 0) var _selfdata = _data.hisEqData.hisOne || null;
						else if(i === 1) var _selfdata = _data.hisEqData.hisSec || null;
						else if(i === 2) var _selfdata = _data.hisEqData.hisThr || null;
						if(_selfdata) {
							$(ev).find('.item-container .container-header .meta-time').text(_selfdata.EarthquakeDate || '无数据');
							$(ev).find('.item-container .container-body .body-header .meta-description').text(_selfdata.Macro_epicenter + parseFloat(_selfdata.Magnitude) + '地震' || '无数据');
							$(ev).find('.item-container .body-container .population .population-num').text(_selfdata.Death || '无数据');
							$(ev).find('.item-container .body-container .area .area-num').text(_selfdata.Area || '无数据');
							$(ev).find('.item-container .body-container .economy .economy-num').text(_selfdata.DirectEconomicLoss || '无数据');
						}else{
							
							$(ev).remove();
							flag++;
							if(flag==3){
								$('.td-history').remove();
							}
						}
					})
				}else{$('.td-history').remove();

				}
			}
			function setIntensityCricle (map, centerPoint, data) {
				data = parseFloat(data.substr(0,1));
		        var R = new Array();//存放半径
		        var I = new Array();//存放罗马数字
		        var cricles = new Array();//存放圆的数组
		        if(data <= 4.5){
		            alert("数据过小",{icon:5});
		            return;
		        }else if(data>= 4.5 && data < 4.7){
		            R = [10];
		            I = ['Ⅵ'];
		        }else if(data >= 4.7 && data < 5.3){
		            R = [5,15];
		            I = ['Ⅵ','Ⅶ'];
		        }else if(data >= 5.3 && data < 5.7){
		            R = [10,30];
		            I = ['Ⅵ','Ⅶ'];
		        }else if(data >= 5.7 && data < 6.3){
		            R = [10,20,40];
		            I = ['Ⅵ','Ⅶ','Ⅷ'];
		        }else if(data >= 6.3 && data < 6.7){
		           R = [5,20,50,100];
		           I = ['Ⅵ','Ⅶ','Ⅷ','Ⅸ'];
		        }else if(data >= 6.7 && data < 7.2){
		            R = [7.5,30,70,150];
		            I = ['Ⅵ','Ⅶ','Ⅷ','Ⅸ'];
		        }else if(data>= 7.2){
		            alert("数据过大",{icon:5});
		            return;
		        }

		        var colorIntensity=['#9A0103','#D03A00','#FFDD04','#82BF24','#AFFF80','#E6FFC8','FFFFCE','D4FFD3','A1E7EA'];//存放颜色

		        for(var i=R.length-1;i>=0;i--){

			        (function(num){
				        var circle = new BMap.Circle( centerPoint , R[num]*1000);
				        circle.setStrokeColor(colorIntensity[num]);
				        circle.setFillColor(colorIntensity[num]); //创建圆
				        circle.setStrokeWeight(1);
				        circle.setFillOpacity(0.3);
				        circle.class="circle";
				        map.addOverlay(circle);
				        cricles.push(circle);
			        })(i)

		        }
		        for(var k=0 ; k<cricles.length ; k++){
			        (function(num){
				        if(num == cricles.length-1){
				            var lat = (centerPoint.lat + cricles[num].ia[0].lat)/2;
				            var lng = (centerPoint.lng + cricles[num].ia[0].lng)/2;
				        }else{
				            var lat = (cricles[num].ia[0].lat - cricles[num+1].ia[0].lat)/2 + cricles[num+1].ia[0].lat;
				            var lng = (cricles[num].ia[0].lng - cricles[num+1].ia[0].lng)/2 + cricles[num+1].ia[0].lng;
				        }
				        var I_point = new BMap.Point(lng,lat);
				        //标注震级
				        var opts = {
				            position : I_point,    // 指定文本标注所在的地理位置
				            offset   : new BMap.Size( -10, -10)    //设置文本偏移量
				        }
				        //实例化label
				        var I_label = new BMap.Label(I[num], opts);  // 创建文本标注对象
				        //改变label样式
				        I_label.setStyle({
				            color : "#000088",
				            backgroundColor:'transparent',//文本背景色
				            borderColor:'transparent',//文本框边框色
				            fontSize : "10px",
				            height : "10px",
				            lineHeight : "10px",
				            fontFamily:"微软雅黑",
				            fontWeight:'bolder'//加粗
				        });
				        map.addOverlay(I_label);
			        })(k)
		        }
			}
			function setMapNearCityDesc(_data,eqmes)
			{
				var citynum = _data.nearCityData.length;
				var cityName ="<p>"+eqmes.time;//加时间
				var intensitry = getRoma(parseInt(eqmes.int));
				cityName = cityName + ",在" + eqmes.province + eqmes.city + "<strong>" + eqmes.name + "</strong>" + "发生一次" + eqmes.magn +"地震";//哪
				cityName = cityName + ",震源深度为" + eqmes.depth + ",最大烈度为" + intensitry + "度" ;
				cityName = cityName + ",周围有"
				for (_city in _data.nearCityData) {
					cityName = cityName + _data.nearCityData[_city].name + ',';
				}
				cityName = cityName + citynum +'个县城!';
				$('.eqtomap .eqtomapdes .text-container').html(cityName || '无数据');
			}
			function setCounty(map, data){
				var option = {
					strokeWeight: 1, 
					strokeColor: "#000",
					StrokeStyle: "dashed", //设置多边形边线样式为实线或虚线，取值 solid 或 dashed
					fillColor: 'transparent', //多边形填充色
					fillOpacity: 0 //设置多边形填充颜色透明度0-1
				}
				var bdary = new BMap.Boundary();
				data.forEach(function(item, index) {

					bdary.get(item.name, function (rs) {
						var count = rs.boundaries.length
						for(var i = 0;i<count;i++) {
							var ply = new BMap.Polygon(rs.boundaries[i], option); //建立多边形覆盖物
            				map.addOverlay(ply);  //添加覆盖物
						}
					})
				})
			}
			function getZhishu(data) {
				 var zhishus = [];
				 var need = ['舒适度', '穿衣指数', '感冒指数', '紫外线强度'];
				 data.forEach(function (value, item) {
				 	if(inarray(value.name, need)) {
				 		zhishus.push(value);
				 	}
				 });
				 return zhishus;
			}
			function inarray(target, arr) {
				var len = arr.length;
				for(var i = 0; i < len; i++) {
					if(target === arr[i]) {
						return true;
					}
				}
				return false;
			}
			function createdZhishufra (data) {
				var fragment = $(document.createDocumentFragment());
				var fraitem = null;
				data.forEach(function (value) {
					fraitem = $('<label class="te-zhishus-item">' + value.name + '<span>' + value.value + '</span></label>');
					fragment.append(fraitem);
				});
				return fragment;
			}
			addFault(center);//断裂带
			function addFault(center){
				var map = new BMap.Map("BMapFault",{
					minZoom : 4,  
       				maxZoom : 11  
				});           // 创建Map实例
				window.mapFault=map;
				var navOpt = {type: BMAP_NAVIGATION_CONTROL_ZOOM};          
				map.addControl(new BMap.NavigationControl(navOpt)); 
				map.centerAndZoom(new BMap.Point(center.lon, center.lat), 8);
				var point = new BMap.Point(center.lon, center.lat); // 创建点坐标
				var centerIcon = new BMap.Icon("IMAGES/mapimg/centerstar2.png", new BMap.Size(20, 20));
				var centerMarker = new BMap.Marker(point, {icon: centerIcon});
				map.addOverlay(centerMarker);
				var eqmes=getEqCenterMes();
				var opts = {
				  position : point,    // 指定文本标注所在的地理位置
				  offset   : new BMap.Size(-80, -30)    //设置文本偏移量
				}
				var label = new BMap.Label(eqmes.province+eqmes.name+eqmes.magn+"地震", opts);  // 创建文本标注对象
					label.setStyle({
						 color : "black",
						 fontSize : "18px",
						 height : "20px",
						 lineHeight : "20px",
						 fontFamily:"斜体",
						 borderColor:'transparent',
		  				 backgroundColor:'transparent'
					 });
				map.addOverlay(label);  
				var linePoints=new Array();
				 var sub=0;
				linePoints[sub]=new Array();
				var info=new Array();
				 info[sub]=new Array();
				 $.ajax({  
				    url : "static/fault_zone_copy_copy.json",  
						datatype: "json",        
						async : false,  
						data :{},  
						success : function(data) {  
							for(var i=0;i+1<data.RECORDS.length;i++){
							      if(data.RECORDS[i].line==data.RECORDS[i+1].line){
							      	var point=new BMap.Point(data.RECORDS[i].baidu_X,data.RECORDS[i].baidu_Y);
							      	linePoints[sub].push(point);
								   }else{
								        var point=new BMap.Point(data.RECORDS[i].baidu_X,data.RECORDS[i].baidu_Y);
								        linePoints[sub].push(point);
								        // if(data.RECORDS[i].name!=""){
								        // 	info[sub].push(data.RECORDS[i].name);
								        // }else{
								        // 	info[sub].push("");
								        // }
								        
								        sub++;
								        linePoints[sub]=new Array();
								        }
						    }
					for(var j=0;j<linePoints.length;j++){
					    if(linePoints[j][0].lng<center.lon+3&&linePoints[j][0].lng>center.lon-3 && linePoints[j][0].lat>center.lat-3&&linePoints[j][0].lat<center.lat+3){
					        var polyline = new BMap.Polyline(linePoints[j],{strokeColor:"red", strokeWeight:2, strokeOpacity:0.5}); 
					            var opts = {
									position : point,    // 指定文本标注所在的地理位置
									offset   : new BMap.Size(30, -30)    //设置文本偏移量
								}
								var label = new BMap.Label("", opts);  // 创建文本标注对象
									label.setStyle({
										color : "red",
										fontSize : "12px",
										height : "20px",
										lineHeight : "20px",
										fontFamily:"微软雅黑",
										borderColor:'transparent',
		  								backgroundColor:'transparent'
									});
									polyline.flag="myfault";
					            } 
					             
					             map.addOverlay(polyline);
					             map.addOverlay(label);
					           }
						    }  
						});
			}
			function addlatLng(map,param){
			    var southWest=map.getBounds().getSouthWest();
			    var northEast=map.getBounds().getNorthEast();

			   for(var i=0;i<(northEast.lng-southWest.lng).toFixed(2);i=i+param){
			      var markerTop=new BMap.Marker(new BMap.Point(southWest.lng+i, northEast.lat));
			      var markerBottom=new BMap.Marker(new BMap.Point(southWest.lng+i, southWest.lat));
			      var optsTop = {
			        position : new BMap.Point(southWest.lng+i, northEast.lat),    // 上边界
			        offset   : new BMap.Size(0,0)    //设置文本偏移量
			      }
			      var labelTop = new BMap.Label((southWest.lng+i).toFixed(2)+'  E', optsTop);  // 创建文本标注对象
			      labelTop.flag="myLable";
			      addLabelStyle(map,labelTop);
			      var optsBottom={
			        position : new BMap.Point(southWest.lng+i, southWest.lat),    // 下边界
			        offset   : new BMap.Size(0, -20)    //设置文本偏移量
			      }
			      var labelBottom = new BMap.Label((southWest.lng+i).toFixed(2)+'  E', optsBottom);
			      labelBottom.flag="myLable";
			      addLabelStyle(map,labelBottom)
			   }
			   for(var j=0;j<(northEast.lat-southWest.lat).toFixed(2);j=j+param){
			      var left=new BMap.Marker(new BMap.Point(southWest.lng,southWest.lat+j));
			      var right=new BMap.Marker(new BMap.Point(northEast.lng,southWest.lat+j));
			      var optsLeft = {
			        position : new BMap.Point(southWest.lng,southWest.lat+j),   //左边界
			        offset   : new BMap.Size(0,0)    
			      }
			      var labelLeft = new BMap.Label((southWest.lat+j).toFixed(2)+'N', optsLeft);  // 创建文本标注对象
			      labelLeft.flag="myLable";
			      addLabelStyle(map,labelLeft);

			      var optsRight = {
			        position : new BMap.Point(northEast.lng,southWest.lat+j),   //右边界
			        offset   : new BMap.Size(-45,0)    
			      }
			      var labelRight = new BMap.Label((southWest.lat+j).toFixed(2)+'N', optsRight);  // 创建文本标注对象
			      labelRight.flag="myLable";
			      addLabelStyle(map,labelRight);

			    }
			  }

			  function addLabelStyle(map,label){   
			      label.setStyle({
			         color : "black",
			         fontSize : "12px",
			         height : "20px",
			         lineHeight : "20px",
			         fontFamily:"微软雅黑",
			         backgroundColor:'transparent',//文本背景色
			         borderColor:'transparent',//文本框边框色
			       });
			       map.addOverlay(label);   
			  }
			  function clearOver(map){
				    var overlays=map.getOverlays();
				    for(var i=0;i<overlays.length;i++){
				      if(overlays[i].flag=="myLable"){
				         map.removeOverlay(overlays[i]);
				      }
				    }
			  }
		}

			

		SuBao.init();
		SuBao.getData();

	})
</script>
</body>
</html>
